<?php

global $conn_handler;

require_once($srvpath."dbconf.php");
//echo 'kuru';
//echo $db_name;

//global $db_name;
//$db_name="cloister";


function ConnectDB() {
	//global $conn_handler;
		//$conn_handler=mysql_connect("localhost", "perpus", "perpus");
		//if (!$conn_handler) {
			//die('Could not connect: ' . mysql_error());
			//echo "nyaa~";
		//}
		//else echo "nyatto";

	$db_host=$GLOBALS['db_host'];
	$db_usr=$GLOBALS['db_usr'];
	$db_pass=$GLOBALS['db_pass'];

	$conn_handler=mysql_connect($db_host, $db_usr, $db_pass);
	if (!$conn_handler) {
		die('Could not connect: ' . mysql_error());
		echo 'die';
	}
	//$GLOBALS['conn_handler']=$conn_handler;
	return $conn_handler;
}

function SelectDB() {
	//echo $GLOBALS['db_name'];
	$db=$GLOBALS['db_name'];
	//echo $db;
	$cnh=$GLOBALS['conn_handler'];
	if (!mysql_query("use ".$db.";", $cnh)) echo 'fail';
}

?>

